@extends('pc_admin.app')

@section('content')
    <link rel="stylesheet" href="/css/pc-system/attendance-left.css">
    <link rel="stylesheet" href="/css/pc-system/attendance-manage.css">
    <div class="mian-container">
        <div class="container-section attendance-manage">
            <div class="f-left left-section">
                <div class="title-list top-list">
                    <h3 class="h3-title" onclick="window.location.href='/admin/set/attendance_edit'"><i class="icon iconfont icon-shezhi"></i>考勤设置</h3>
                </div>
                @foreach($tongxunlu as $t)
                    <div class="section-list">
                        <div class="title-list" id="{{$t['id']}}">
                            <h3 class="h3-title">
                                @if($t['group_name'] != '我的同事')
                                    <img class="list-user" src="/img/list-user1.png" style="vertical-align: middle; width: 18px;  height: 18px;">
                                @endif{{$t['group_name']}}
                            </h3>
                            <span class="num-span"></span>
                        </div>
                        <ul>
                            @foreach($t['member'] as $m)
                                <li>
                                    <a href="attendance/{{$m['id']}}" style="display: inline-block;height: 100%;width: 100%;">
                                        <img class="sec-img" src="{{userlogo($m['id'])}}">
                                        <span class="sec-name">{{$m['qw_name']}}</span>
                                        @foreach($m['role'] as $mr)
                                            <span class="circle-span @if($mr==10) span-score @elseif($mr==11) span-exam @elseif($mr==12) span-reward @endif">{{$roleArray[$mr]}}</span>
                                        @endforeach
                                    </a>
                                </li>
                            @endforeach
                        </ul>
                        @if(isset($t['child']))
                            @foreach($t['child'] as $c)
                                <div class="second-list">
                                    <div class="title-list" id="{{$c['id']}}">
                                        <h3 class="h3-title"><img class="list-user" src="/img/list-user1.png" style="vertical-align: middle; width: 18px;  height: 18px;"> {{$c['group_name']}}</h3>
                                        <span class="num-span"></span>
                                    </div>
                                    <ul>
                                        @foreach($c['member'] as $cm)
                                            <li>
                                                <a href="attendance/{{$cm['id']}}" style="display: inline-block;height: 100%;width: 100%;">
                                                    <img class="sec-img" src="{{userlogo($cm['id'])}}">
                                                    <span class="sec-name">{{$cm['qw_name']}}</span>
                                                    @if($cm['is_leader'] == 1)<i class="icon iconfont icon-qizi"></i>@endif
                                                    @foreach($cm['role'] as $cmr)
                                                        <span class="circle-span @if($cmr==10) span-score @elseif($cmr==11) span-exam @elseif($cmr==12) span-reward @endif">{{$roleArray[$cmr]}}</span>
                                                    @endforeach
                                                </a>
                                            </li>
                                        @endforeach
                                    </ul>
                                    @foreach($c['child'] as $cc)
                                        <div class="third-list">
                                            <div class="title-list" id="{{$cc['id']}}">
                                                <h3 class="h3-title"><img class="list-user" src="/img/list-user1.png" style="vertical-align: middle; width: 18px;  height: 18px;"> {{$cc['group_name']}}</h3>
                                                <span class="num-span"></span>
                                            </div>
                                            <ul>
                                                @foreach($cc['member'] as $ccm)
                                                    <li>
                                                        <a href="attendance/{{$ccm['id']}}" style="display: inline-block;height: 100%;width: 100%;">
                                                            <img class="sec-img" src="{{userlogo($ccm['id'])}}">
                                                            <span class="sec-name">{{$ccm['qw_name']}}</span>
                                                            @if($ccm['is_leader'] == 1)<i class="icon iconfont icon-qizi"></i>@endif
                                                            @foreach($ccm['role'] as $ccmr)
                                                                <span class="circle-span @if($ccmr==10) span-score @elseif($ccmr==11) span-exam @elseif($ccmr==12) span-reward @endif">{{$roleArray[$ccmr]}}</span>
                                                            @endforeach
                                                        </a>
                                                    </li>
                                                @endforeach
                                            </ul>
                                        </div>
                                    @endforeach
                                </div>
                            @endforeach
                        @endif
                    </div>
                @endforeach
            </div>
            <div class="right-section center-list">
            </div>
        </div>
    </div>

    <script>
        $(document).ready(function () {
            $('.h3-title').parent().siblings('ul').css('display','none');
            $('.center-list').css('min-height',$('.left-section').height());
            $('.num-span').each(function(){
                $(this).text($(this).parent().next('ul').children().length);
            });
            $('.h3-title').each(function () {
                var that= this
                if($(that).text().trim()=='我的同事'){
                    //$(that).parent().addClass('active');
                    $('.center-list').html($(that).parent().next('ul').html());
                }
            });
            $('.icon-qizi').prev('.sec-name').css('color','#F46555')
            $('.title-list').click(function () {
                $(this).parents().find('.title-list').removeClass('active');
                $(this).addClass('active');
                $('.center-list').html($(this).next('ul').html());
            })
        })
        var ugid = {{$active}};
        $('#'+ugid).addClass('active');
        $('.head_kaoqin').addClass('active');
    </script>
@endsection